
function main() {
    var testVersion = "(201901021555)版";
    var softwareName = "抖音";
    var view = RequestEngine.getWebView();
    var viewJson = JSON.parse(view);
	var search = viewJson.search;
	var fanYeNum = viewJson.number;
    var contentArr = viewJson.contentArr;

    var fenSiNumF=0;
	AccessibilityEngine.sleepEngine(2000);//等待
	if (AccessibilityEngine.checkUpId(widget.pages.shouye.exit) == ISTRUE) { //取消
        AccessibilityEngine.mockOnClickId(widget.pages.shouye.exit);
    }
	AccessibilityEngine.sleepEngine(2000);//等待
	if (AccessibilityEngine.checkUpId(widget.pages.shouye.wzdl) == ISTRUE) { //我知道了
        AccessibilityEngine.mockOnClickId(widget.pages.shouye.wzdl);
    }
    
	var jixing = getXYByIdIndex(widget.pages.shouye.wode);
	
    AccessibilityEngine.sleepEngine(10000);//等待
    AccessibilityEngine.mockOnClickId(widget.pages.shouye.shousuo); // 点击搜索 放大镜

    if (AccessibilityEngine.checkUpId(widget.pages.shouye.bugengxin) == ISTRUE) {//更新以后再说
        AccessibilityEngine.mockOnClickId(widget.pages.shouye.bugengxin);
    }
    if( jixing == 1 ){
        ScreenEngine.swipe(parseX(300), parseY(100), parseX(300), parseY(100), 500); //点击
    } else if( jixing == 2 ){
        ScreenEngine.swipe(parseX(400), parseY(100), parseX(400), parseY(100), 500); //点击
    }else if( jixing == 3 ){
        ScreenEngine.swipe(parseX(300), parseY(72), parseX(300), parseY(72), 500); //点击
		showLog("jixing == 3 ");
		//AccessibilityEngine.mockOnClickId("com.ss.android.ugc.aweme:id/b15");
		AccessibilityEngine.sleepEngine(3000);//等待
    }
	AccessibilityEngine.sleepEngine(1000);//等待
    AccessibilityEngine.mockEditId(widget.pages.shouye.shousuopinglunKuang,search); //赋值搜索框
    if (AccessibilityEngine.checkUpId(widget.pages.shouye.bugengxin) == ISTRUE) {//更新以后再说
        AccessibilityEngine.mockOnClickId(widget.pages.shouye.bugengxin);
    }
    
	AccessibilityEngine.sleepEngine(2000);//等待
	
   //搜索按钮
    if (jixing == 1) {
        ScreenEngine.swipe(parseX(665), parseY(1219), parseX(665), parseY(1219), 500); //点击
    } else if (jixing == 2) {
		AccessibilityEngine.sleepEngine(5000);//等待
		//ScreenEngine.swipe(parseX(480), parseY(715), parseX(480), parseY(715), 500); //点击	
		ScreenEngine.swipe(parseX(700), parseY(1200), parseX(700), parseY(1200), 500); //点击
    }else if( jixing == 3 ){
        ScreenEngine.swipe(parseX(667), parseY(90), parseX(667), parseY(90), 500); //点击
    }
      
    AccessibilityEngine.sleepEngine(1000);//等待
	
	if (AccessibilityEngine.checkUpIdText("android:id/text1","用户")== ISTRUE) {
            AccessibilityEngine.mockOnClickIdText("android:id/text1","用户") //  //点击搜索框后出现的搜索按钮后出现的页面的用户
    }
	AccessibilityEngine.sleepEngine(5000);//等待
	
	if (AccessibilityEngine.checkUpId(widget.pages.shousuoyemian.touxiang) == ISTRUE) { //点击第一个头像
        AccessibilityEngine.mockOnClickId(widget.pages.shousuoyemian.touxiang);
    }else{
		//该用户还没有发布视频
		setTaskState("5", "脚本执行完毕!  该用户还没有发布视频,请换符合的账号执行");
	}
	AccessibilityEngine.sleepEngine(1000);//等待
	if (AccessibilityEngine.checkUpId(widget.pages.shousuoyemian.fensiguanzu) == ISTRUE) { //关注
        AccessibilityEngine.mockOnClickId(widget.pages.shousuoyemian.fensiguanzu);
    }
	AccessibilityEngine.sleepEngine(1000);//等待
	if (AccessibilityEngine.checkUpId(widget.pages.shousuoyemian.shipinkuang) == ISTRUE) { //点击第一个视频
        AccessibilityEngine.mockOnClickId(widget.pages.shousuoyemian.shipinkuang);
    }else{
		setTaskState("5", "执行成功,但没有视屏");
		throw SyntaxError();
	}
	//判断有无评论(没有评论会直接跳进 留下你的精彩评论)
	if(AccessibilityEngine.checkUpIdText("com.ss.android.ugc.aweme:id/sl", "评论并转发") == ISTRUE){
		AccessibilityEngine.sleepEngine(2000);//等待
		setTaskState("5", "脚本执行完毕!  该用户没有评论,请换符合的账号执行");
	}
	
	AccessibilityEngine.sleepEngine(1000);//等待
	//pinlunkuang();
	//1代表小米4a，2代表红米note2
	if( jixing == 1 ){// 进评论
		//var pressjixing = "press," + parseX(660) + "," + parseY(757);
		//ScreenEngine.currency(pressjixing);
		ScreenEngine.swipe(parseX(660), parseY(717), parseX(660), parseY(717), 500); //从下往上滑动
	}else if( jixing == 2 ){
		ScreenEngine.swipe(parseX(667), parseY(760), parseX(667), parseY(760), 500); //从下往上滑动
	}else if( jixing == 3 ){
		showLog("jixing == 3   进评论 ");
		ScreenEngine.swipe(parseX(990), parseY(1262), parseX(990), parseY(1262), 1500); //从下往上滑动
	}
	
	//判断有无评论(没有评论会直接跳进 留下你的精彩评论)
	if(AccessibilityEngine.checkUpIdText("com.ss.android.ugc.aweme:id/sl", "评论并转发") == ISTRUE){
		AccessibilityEngine.sleepEngine(2000);//等待
		setTaskState("5", "脚本执行完毕!  该用户没有评论,请换符合的账号执行");
	}
	
	AccessibilityEngine.sleepEngine(1000);//等待

	for (var fanYeNumF = 0; fanYeNumF < fanYeNum; fanYeNumF++) { 
	
		if (AccessibilityEngine.checkUpId(widget.pages.shouye.bugengxin) == ISTRUE) {//更新以后再说
			AccessibilityEngine.mockOnClickId(widget.pages.shouye.bugengxin);
		}
		
	
		AccessibilityEngine.sleepEngine(1000);//等待
		
		//点击第一个小头像
		ScreenEngine.swipe(parseX(65), parseY(333), parseX(65), parseY(333), 500); //点击
        AccessibilityEngine.sleepEngine(5000);//等待
		
		//点击 进入评论转发
		if(AccessibilityEngine.checkUpIdText("com.ss.android.ugc.aweme:id/sl", "评论并转发") == ISTRUE){
			AccessibilityEngine.sleepEngine(2000);//等待
			AccessibilityEngine.mockBack();
		}
		
		//正常进入用户页面
		if(AccessibilityEngine.checkUpIdText("com.ss.android.ugc.aweme:id/ciy", "关注") == ISTRUE || AccessibilityEngine.checkUpIdText("com.ss.android.ugc.aweme:id/ame", "取消关注") == ISTRUE){
			
			if (AccessibilityEngine.checkUpId(widget.pages.shouye.bugengxin) == ISTRUE) {//更新以后再说
				AccessibilityEngine.mockOnClickId(widget.pages.shouye.bugengxin);
			}
			AccessibilityEngine.sleepEngine(1000);//等待
			if (AccessibilityEngine.checkUpId(widget.pages.shousuoyemian.fensiguanzu) == ISTRUE) { //关注按钮 
				AccessibilityEngine.mockOnClickId(widget.pages.shousuoyemian.fensiguanzu);
			}
			
			AccessibilityEngine.sleepEngine(3000);//等待
			if (AccessibilityEngine.checkUpText("对方已设置为私密帐号，需要对方通过请求后才能成功关注哦～") == ISTRUE  || AccessibilityEngine.checkUpIdText("android:id/message", "对方已设置为私密帐号，需要对方通过请求后才能成功关注哦～") == ISTRUE  || AccessibilityEngine.checkUpId("android:id/message") == ISTRUE ) { //私密账号 
				AccessibilityEngine.sleepEngine(2000);
				AccessibilityEngine.mockBack();
				AccessibilityEngine.sleepEngine(2000);
				AccessibilityEngine.mockBack();
				AccessibilityEngine.sleepEngine(2000);
				continue;
			}
			
			AccessibilityEngine.sleepEngine(3000);//等待  //已请求...
			if (AccessibilityEngine.checkUpText("已请求") == ISTRUE  || AccessibilityEngine.checkUpIdText("com.ss.android.ugc.aweme:id/c9g", "已请求") == ISTRUE  || AccessibilityEngine.checkUpId("com.ss.android.ugc.aweme:id/c9g") == ISTRUE ) { //私密账号 
				AccessibilityEngine.sleepEngine(2000);
				AccessibilityEngine.mockBack();
				AccessibilityEngine.sleepEngine(2000);
				AccessibilityEngine.mockBack();
				AccessibilityEngine.sleepEngine(2000);
				continue;
			}
			
			AccessibilityEngine.sleepEngine(1000);//等待
			if (AccessibilityEngine.checkUpId(widget.pages.shousuoyemian.faxiaoxianniu) == ISTRUE) { //发消息按钮
				AccessibilityEngine.mockOnClickId(widget.pages.shousuoyemian.faxiaoxianniu);
			}
			AccessibilityEngine.sleepEngine(1000);//等待
			
			if (AccessibilityEngine.checkUpId(widget.pages.shouye.bugengxin) == ISTRUE) {//更新以后再说
				AccessibilityEngine.mockOnClickId(widget.pages.shouye.bugengxin);
			}
			
			var search2 = contentArr[Math.floor(Math.random()*contentArr.length)];
			AccessibilityEngine.mockEditId(widget.pages.fasongxiaoxi.fasongxiaoxikuang, search2); //消息框赋值
			AccessibilityEngine.mockOnClickId(widget.pages.fasongxiaoxi.fasonganniu); // 发送
			AccessibilityEngine.sleepEngine(1000);//等待
			if (AccessibilityEngine.checkUpId(widget.pages.pinglunKuang.fanhui) == ISTRUE) { //返回
				AccessibilityEngine.mockOnClickId(widget.pages.pinglunKuang.fanhui);
			}
			AccessibilityEngine.sleepEngine(1000);//等待
			if (AccessibilityEngine.checkUpId(widget.pages.shousuoyemian.guanzuyemianfanhui) == ISTRUE) { //在返回
				AccessibilityEngine.mockOnClickId(widget.pages.shousuoyemian.guanzuyemianfanhui);
			}
			AccessibilityEngine.sleepEngine(1000);//等待
		}else{
			fanYeNumF--;
		}
		
		//下滑
		if(AccessibilityEngine.checkUpText("暂时没有更多了") == ISFALSE){
			ScreenEngine.swipe(parseX(64), parseY(517), parseX(64), parseY(337), 1000);
		}else{
			setTaskState("5", "执行成功,已经滑到底部,请换符合的账号执行");
		}
    }

    setTaskState("5", "执行成功");
	
	function pinlunkuang() {
        AccessibilityEngine.sleepEngine(1000);//等待
        var pressDianZan = "press," + parseX(659) + "," + parseY(760);
        ScreenEngine.currency(pressDianZan);
        AccessibilityEngine.sleepEngine(50);
        ScreenEngine.currency(pressDianZan);
        AccessibilityEngine.sleepEngine(50);
        ScreenEngine.currency(pressDianZan);
        AccessibilityEngine.sleepEngine(50);
        ScreenEngine.currency(pressDianZan);
        AccessibilityEngine.sleepEngine(50);
        ScreenEngine.currency(pressDianZan);
        AccessibilityEngine.sleepEngine(50);
        ScreenEngine.currency(pressDianZan);
        AccessibilityEngine.sleepEngine(1000);//等待
    }
}

var publicfunction = RequestEngine.getPluginPath() + "OS_DYCOMMON/publicfunction.js";
include(publicfunction); //公共方法js
var widgetPath = dyConditionCheck();
var widgetbyid = RequestEngine.getPluginPath() +"OS_DYCOMMON/"+ widgetPath;
include(widgetbyid);
main();